<?php
include '../../auth/ceklogin.php';
include '../../sql/conn.php';

$namaCustomer=$_REQUEST['namaCustomer'];
$alamatCustomer=$_REQUEST['alamatCustomer'];
$attnCustomer=$_REQUEST['attnCustomer'];
$telpCustomer=$_REQUEST['telpCustomer'];
$faxCustomer=$_REQUEST['faxCustomer'];
$keterangan=$_REQUEST['keterangan'];

$queryi=mysql_query("SELECT idCustomer FROM `customer` order by idCustomer DESC limit 0,1");
$row=mysql_fetch_array($queryi);
$row=$row[0]+1;
$query=mysql_query(" 
    INSERT INTO `customer` (
        `idCustomer`
        ,`namaCustomer`
        ,`alamatCustomer`
        ,`attnCustomer`
        ,`telpCustomer`
        ,`faxCustomer`
        ,`keterangan`
        ,`last_update`
    )
    VALUES 
    (
        '$row'
        , '$namaCustomer'
        , '$alamatCustomer'
        , '$attnCustomer'
        , '$telpCustomer'
        , '$faxCustomer'
        , '$keterangan'
        , date_format(now(),\"%Y-%m-%d\")
    )
");
if($query){
    echo json_encode(array('success'=>true,'msg'=>'Customer : '.$namaCustomer.' successfully Created.'));
} else {
    echo json_encode(array('msg'=>'Error Occured.'.  mysql_error()));
}
?>